// miniprogram/pages/at/answerFinished.js
Page({
  _upLoadRes: function(){
    let collection_name = ''
    let userid = ''
    wx.cloud.database().collection(collection_name).add({
      userid: userid,
      accuracy: this.data.accuracy,
      score: this.data.score
    }).catch(err => {
      console.log(err)
    })
  },
  /**
   * 页面的初始数据
   */
  data: {
    total: 0,
    minutes: 0,
    seconds: 0,
    accuracy: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log("options = ", options)
    let a = options.time
    let minutes = Math.floor(a/60000)
    let seconds = Math.round((a - minutes * 60000) / 1000)
    let total = options.total
    let accuracy = Math.round( 100 * options.correct / total)
    let score = options['score']
    if(score){
      this.setData({score: score})
    }
    this.setData({
      total: total,
      minutes: minutes,
      seconds: seconds,
      accuracy: accuracy
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})